<template>
  <div class="hoter">
    <van-nav-bar
      :title="titlename"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <div class="post">
      <div class="left">
        <div class="head">
          <div class="image">
            <img :src="imgshow" alt="" style="width: 2rem; height: 2rem" />
          </div>
          <div class="name">
            <div class="news">{{ address }}</div>
            <div class="data">{{ time }}</div>
          </div>
        </div>
      </div>
      <div class="right"><van-icon name="chat-o" size="1.5rem" />{{ num }}</div>
    </div>
    <div v-html="username" class="all"></div>
    <!-- 底部tablebar -->
  </div>
</template>


<script setup>
import { onMounted, ref, reactive } from "vue";
import { yaodetails } from "../api/getlogin";
import { useRoute } from "vue-router";
const route = useRoute();
const username = ref("");
const list = reactive([]);
const num = ref(0);
const titlename = ref("文章详情");
const address = ref("");
const time = ref("");
const imgshow = ref("");
const onClickLeft = () => history.back();
onMounted(async () => {
  const { data: res } = await yaodetails();
  list.value = res;
  // console.log(list);
  list.value.forEach((e, index) => {
    if (e.id == route.query.id) {
      list.value = e;
      username.value = res[index].textarea;
      titlename.value = res[index].title;
      imgshow.value = res[index].img;
      address.value = res[index].tem;
      time.value = res[index].time;
      num.value = res[index].num;
    }
  });

  // console.log(res);
});

onMounted(async () => {
  // console.log(route.query.id);
});
</script>
 


<style>
.hoter {
  width: 100vw;
  height: 90vh;
  overflow: scroll;
}

.all {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-top: 10px;
}

.all section {
  width: 100vw;
  text-align: justify;
  word-break: break-all;
}

.all img {
  width: 100%;
  height: auto;
}

#container {
  width: 22rem;
}

.preset-original-title {
  font-weight: 600;
  font-size: 1.5rem;
  text-align: left;
  margin-left: 5px;
  margin-top: 3rem;
}

.post {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  position: relative;
  top: 5px;
  left: -35px;
}

.head {
  display: flex;
  flex-direction: row;
  justify-content: center;
}

.data {
  font-size: 1rem;
  color: #b4b4b4;
}

.news {
  font-size: 1rem;
  font-weight: 500;
}

.image {
  margin-right: 6px;
}
</style>